home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEV / I-Z / ResExpress 1.0.sea / ResExpress 1.0 / ResX DevKit / Think Pascal / RXXT Shell w_Globals.p < prev    next >
Text File  |  1990-01-04  |  6KB  |  145 lines

  1. unit RXXTShell;
  2.  
  3. {RXXT Shell for ResX Externals}
  4.  
  5. {To compile in Think Pascal:}
  6.  
  7. {   1) Set Project Type to 'Code Resource' }
  8. {   2) Set the File TYPE to 'RXXT' and File Creator to 'ResX'}
  9. {   3) Set the Resource TYPE to 'RXXT' }
  10. {   4) Set the Resource NAME to the name of the external as it should appear in the}
  11. {        Externals menu.  A hex editor external could be named 'Hex Editor'.}
  12. {   5) Add this file, DRVRRuntime.lib, and Interface.lib to the project }
  13. {   6) Compile the code resource. }
  14. {   7) Install it in ResX via the 'Externals->Install' menu.  Or double-click on the external file in Finder. }
  15.  
  16.  
  17.  
  18.  
  19. {PRE-CONDITIONS}
  20. {    1) The handle to the current selected resource is passed directly into main.}
  21. {    2) The resource of that handle is NOT loaded.  It must be loaded if used.}
  22. {    3) The handle to the resource is NOT detached!}
  23. {    4) The Global Data address is stored in the reference constant of the daWindow.  See example below on}
  24. {         how to access the globals.}
  25. {    5) It is mandatory to get the state of the handle (HGetState).  Restore the state when finished.}
  26.  
  27.  
  28. {POST-CONDITIONS}
  29. {    1) Do NOT release the resource or dispose the handle to the resource.  ResX will do it when}
  30. {        necessary.  ResX will check to see if the resource has been loaded by another environment.}
  31. {    2) Restore the state of the handle when finished (HSetState).}
  32.  
  33.  
  34. {EXCEPTIONS}
  35. {    1) If writing an external that does not deal with the current selected resource (such as a}
  36. {        'Copy Data Fork' external or maybe one that acts on all resources), it is not necessary to}
  37. {        load the resource (ResHandle) and it is not necessary to save/restore the handle state }
  38. {        (HGetState/HSetState not required).}
  39.  
  40.  
  41.  
  42. interface
  43.     procedure main (ResHandle: Handle);  {Handle of the current selected resource}
  44.  
  45.  
  46. implementation
  47.     procedure main;
  48.         type
  49.  
  50.             SettingsHandle = ^SettingsPtr;                    {Contains Configuration setup, last and second}
  51.             SettingsPtr = ^SettingsRec;                        {to last files opened, and last move info}
  52.             SettingsRec = record
  53.                     unused1: Boolean;
  54.                     openStartup: Boolean;                            {Enable/Disable Open on Startup options}
  55.                     sortTList, sortRList: Boolean;                {Sort Type/Resource list}
  56.                     lastOneRefNum, lastTwoRefNum: integer;    {Last/Second to last volume reference number}
  57.                     lastOneName, lastTwoName: Str255;        {Last/Second to last file name}
  58.                     lastMoveType: ResType;                        {TYPE of the last resource copied}
  59.                     lastMoveID: integer;                            {Resource ID of the last resource copied}
  60.                     lastMoveSource, lastMoveDest: Str255;    {Source and Dest Files of the last resource copied}
  61.                     onStartup: integer;                                {Open on startup option: 1-Last File, 2-Last Two Files, 3-Open File Dialog}
  62.                     unused2: integer;
  63.                     dClick: integer;                                    {Current selected item of DoubleClick popup menu}
  64.                     helpFName: Str255;                            {Location of master Help file}
  65.                 end;
  66.  
  67.  
  68.  
  69.             GlobalsHndl = ^GlobalsPtr;                        {ResX Global Data - Most data can be programmably}
  70.             GlobalsPtr = ^GlobalsRec;                        {altered.  Alter with care!    * denotes DO NOT alter}
  71.             GlobalsRec = record
  72.                     theDevCtlEnt: DCtlPtr;                        {*Device Control Entry for DA*}
  73.                     rsrcBase: Integer;                            {*Resource Base*}
  74.                     daMenu: MenuHandle;                        {Main DA Menu}
  75.                     daFileID: Longint;                            {*File ID of DA*}
  76.  
  77.                     LeftFName, RightFName: Str255;            {Path and Name of Left & Right files currently opened}
  78.                     LeftVNum, RightVNum: integer;            {vRefNum of Left & Right files}
  79.                     LWasOpened, RWasOpened: Boolean;        {Left/Right file was opened priorly and shouldn't be closed}
  80.                     LcurType, RcurType: ResType;            {Current type displayed above resource lists}
  81.                     LTcurCell, RTcurCell: Cell;                {Current selected cell in Left/Right TYPE list}
  82.                     LRcurCell, RRcurCell: Cell;                {Current selected cell in Left/Right RESOURCE list}
  83.                     LfileID, RfileID: integer;                    {Left/Right File ID}
  84.                     prefsID: integer;                            {File ID of ResX Prefs in the System Folder}
  85.                     CompactLeft, CompactRight: Boolean;    {Left/Right resource map will be compacted when closed if TRUE}
  86.                     favMenu, extMenu, openMenu: MenuHandle;        {*Favorite File/Externals/Open File MenuHandles}
  87.                     Lopen, Ropen: Boolean;                        {True if Left/Right file is open and displayed in ResX}
  88.                     MFActive: Boolean;                        {*True if MultiFinder is running*}
  89.                     Settings: SettingsHandle;                    {Handle to Settings in Configuration setup}
  90.  
  91.                     LTypeList: ListHandle;                        {Handle to Left Type list}
  92.                     RTypeList: ListHandle;                        {Handle to Right Type list}
  93.                     LResList: ListHandle;                        {Handle to Left Resource list}
  94.                     RResList: ListHandle;                        {Handle to Right Resource list}
  95.  
  96.  
  97.                     Info: ControlHandle;                           {Get Info Button Control Handle}
  98.                     View: ControlHandle;                       {View Button Control Handle}
  99.                     OpenLeft: ControlHandle;                   {Open Left Button Control Handle}
  100.                     OpenRight: ControlHandle;                  {Open Right Button Control Handle}
  101.                     Remove: ControlHandle;                     {Remove Button Control Handle}
  102.                     Copy: ControlHandle;                       {Copy Button Control Handle}
  103.  
  104.  
  105.                 end;                                            {DO NOT alter globals denoted with *.  They can}
  106.                                                         {be accessed for reference only.}
  107.         var
  108.             fileID, rsrID: integer;
  109.             rsrType: ResType;
  110.             rsrName, fName: Str255;
  111.             HState: SignedByte;
  112.             MF: Boolean;
  113.             Globals: GlobalsPtr;
  114.  
  115.     begin
  116.         Globals := GlobalsPtr(WindowPeek(FrontWindow)^.refCon);    {Required to access the Global Data}
  117.  
  118.  
  119.      {Sample of accessing the global data: }
  120.         fileID := Globals^.LFileID;                                        {Get the file id left file}
  121.         fName := Globals^.LeftFName;                                    {Get the file name of the left file}
  122.         MF := Globals^.MFActive;                                        {Is MultiFinder running?}
  123.  
  124.  
  125.         HState := HGetState(ResHandle);                                {This is mandatory!}
  126.  
  127.  
  128.         LoadResource(ResHandle);                                          {This is necessary if you plan to use it. }
  129.                                                                                        {ResX doesn't load it.}
  130.  
  131.  
  132.  
  133.      {.......}
  134.      {main code here}
  135.      {.......}
  136.  
  137.  
  138.  
  139.         HSetState(ResHandle, HState);                                      {This is mandatory!}
  140.  
  141.      {Do NOT release the resource or dispose the handle, ResX will do it if necessary. }
  142.      {This is critical in case the resource is being used by a currently running application. }
  143.  
  144.     end;
  145. end.